
<%
  var slugs = Object.keys(public.blog._data.posts);
  var blog = _.map(slugs, function(i) { return { 'slug': i, 'author': public.blog._data.posts[i].author, 'title': public.blog._data.posts[i].title, 'date': public.blog._data.posts[i].date, 'published': public.blog._data.posts[i].published}})
  blog = _.sortBy(blog, 'date').reverse().slice(0,5)
  // only show the latest two posts
  blog = blog.slice(0, 2);
%>
<section class="Blog p-t-4 p-b-4" id="blog">
  <div class="container">
    <div class="row">
      <div class="col-xs-12">
        <h3 class="WithDash m-b-1">TRUFFLE BLOG</h3>
        <h5 class="m-b-3">Read the latest from our development blog.</h5>
        <ol class="list-unstyled">
          <% for(var post of blog){ %>
            <% if(!!post.published) { %>
            <li>
              <a href="/blog/<%= post.slug %>">
                <h2><%= post.title %></h2>
                <span>
                  <date><%= post.date %></date> &bull; <span>BY <%=post.author %></span>
                </span>
                <div>Read Blog Post &rarr;</div>
              </a>
            </li>
            <% } %>
          <% }; %>
        </ol>
      </div>
    </div>
  </div>
  <div class="container">
    <div class="row">
      <div class="col-xs-12 text-center">
        <p><a class="btn btn-primary m-t-2" href="/blog">See All Blog Posts &rarr;</a></p>
      </div>
    </div>
  </div>
</section>
